/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2023 —10 —10
 * Time: 18:22
 */


public class test_10_10 {
    /*
    public static void fun(int a){
        if(a == 1){
            return;
        }
        System.out.println(a);
        fun(a-1);                      //  除了1不打印其它都打印
    }

    public static void main(String[] args) {
        fun(10);
    }
    */

/*

    public static void fun(){
        fun();

    }
    public static void main(String[] args) {
        fun();
    }
    //栈溢出错误。
    */


    /*
    public static int fuc(int a){
        if(a == 1){
            return 1;
        }

        int tem = a * fuc(a-1);
        return tem;
    }

    public static void main(String[] args) {
        System.out.println(fuc(7));
    }
    */

    /*
    //打印一个数字的各个位置
    public static void fun(int a){
        if(a < 10 ){
            System.out.print(a);
            return;
        }
        fun(a/10);
        System.out.print(a%10);
    }
    public static void main(String[] args) {

        fun(1234);

    }
    */
    public static int fun(int a){
        int ret = 0;
        if(a < 10 ){
            return a;

        }

        return a%10 + fun(a/10);
    }
    public static void main(String[] args) {

        System.out.println(fun(12345));

    }

}
